package org.brisling.sysman.queryService;

import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;

import org.brisling.base.service.AbstractBaseQueryService;
import org.brisling.common.ConstSysParam;
import org.brisling.sysman.domain.Users;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;

@SuppressWarnings("rawtypes")
@RestController
@RequestMapping("/charts")
public class QueryChartService extends AbstractBaseQueryService{
	
	@SuppressWarnings("unchecked")
	public QueryChartService(){
		this.moduleName = ConstSysParam.MODULE_USER;
		this.subSystem = ConstSysParam.SUBSYSTEM_SYSMAN;
		this.tableName = ConstSysParam.VIEW_PREFIX+this.getTableName(Users.class);
		this.clazz = Users.class;
	}
	
	@PersistenceContext(unitName=ConstSysParam.SUBSYSTEM_SYSMAN)
	@Autowired
	protected void setEntityManager(EntityManager entityManager){
		this.entityManager = entityManager;		
	}
	
	@RequestMapping("/dutiesChart.action")
	public ModelAndView getMainPage(){
		this.subSystem = ConstSysParam.SUBSYSTEM_DUTIES;		
		this.moduleName="duties_chart";
		return this.getBizMainPage();
	}
	
	@RequestMapping("/medicalChart.action")
	public ModelAndView getDeptUserPage(){
		
		this.subSystem = ConstSysParam.SUBSYSTEM_MEDICAL;		
		this.moduleName="medical_chart";
		return this.getBizMainPage();
	}
	
	@RequestMapping("/satisfactionChart.action")
	public ModelAndView getDeptPatientPage(){
		this.subSystem = ConstSysParam.SUBSYSTEM_STATISFACTION;		
		this.moduleName="satisfaction_chart";
		return this.getBizMainPage();
	}
	
	@RequestMapping("/supplyChart.action")
	public ModelAndView getDeptOutpatientPage(){
		this.subSystem = ConstSysParam.SUBSYSTEM_SUPPLY;		
		this.moduleName="supply_chart";
		return this.getBizMainPage();
	}
	
	
	
	/* (non-Javadoc)
	 * @see org.brisling.service.sysman.DepartmentServiceInf#getEditPage()
	 */
	@RequestMapping("/editPage.action")
	public ModelAndView getEditPage(){
		return this.getBizEditPage();
	}
}
